<?php
include "inc/db_connect.php";
include "inc/functions.php";
session_start();
MySQL_Query("SET Character_Set_Client = cp1250");
MySQL_Query("SET Character_Set_Results = cp1250");
MySQL_Query("SET Character_Set_Connection = cp1250");
$zam_s = "SELECT * FROM z WHERE spolid='46'";
$zam_q = MySQL_Query ($zam_s);
echo '<table>';
echo '<tr>';
echo '<th>Meno';
echo '</th>';
echo '<th>Priezvsiko';
echo '</th>';
echo '<th>Tvorí dochádzky';
echo '</th>';
echo '<th>Email';
echo '</th>';
echo '<th>Heslo';
echo '</th>';
echo '</tr>';
while ($zam = MySQL_Fetch_Array($zam_q)) {
    echo '<tr>';
    echo '<td>';
    echo $zam['meno'];
    echo '</td>';
    echo '<td>';
    echo $zam['priezvisko'];
    echo '</td>';
    echo '<td>';
    if ($zam['veduci_oddelenia']==1)
        echo 'Áno';
    else
        echo 'Nie';
    echo '</td>';
    echo '<td>';

    $meno = filterDiacritics(trim($zam['meno']));
    $priezvisko = filterDiacritics(trim($zam['priezvisko']));

    $mail = toLower($meno) .'.'. toLower($priezvisko) . '@falkensteiner.com';
    echo $mail;
    echo '</td>';
    echo '<td>';
    $pass = toLower($meno[0]) . toLower($priezvisko[0]) . 'falkFALK';
    echo $pass;
    echo '</td>';
    echo '</tr>';

    $uloz_u = "UPDATE z SET mail='".$mail."',ip='',heslo='".md5(trim($pass))."',datum_zmeny='".date("Y-m-d")."',datum_prichodu='2011-08-29',datum_pridania='2011-08-29' WHERE id = '".$zam['id']."'";
    $uloz_q = MySQL_Query ($uloz_u);
}
echo '</table>';

$filename ="ExportFalk.xls";
header("http-equiv='content-type' content='text/html; charset=windows-1250'");
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=export_".$filename );
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
?>
